<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2022-10-23
 * Time: 20:07
 */

namespace App\controller\wechat;
use App\model\WechatApp;
use support\exception\Forbidden;
use support\Request;

class App
{
    public function index(Request $request)
    {
        $w=new WechatApp();
        $page=$request->get('page',1);
        $page_size=$request->get('page_size',10);
        return json($w->page($page,$page_size)->select());
    }

    public function add(Request $request)
    {
        $post=$request->post();
        $w= WechatApp::create($post);
        return json($w);
    }
    public function edit(Request $request)
    {
        $post=$request->post();
        if(isset($post['id'])){
            $wa=WechatApp::update($post);
            return json($wa);
        }
        throw new Forbidden('没有传入ID');
    }
}